import { Component, Input } from '@angular/core';

@Component({
    selector: 'app-read-more',
    templateUrl: 'read-more.component.html',
    styleUrls: ['read-more.component.scss']
})
export class ReadMoreComponent {
    @Input() text: string;
    @Input() charLimit = 120;
    @Input() verb = 'Read';

    public showAll = false;

    get displayText() {
        if (this.text === null) {
            return '';
        }

        if (this.showAll || (this.text.length <= this.charLimit)) {
            return this.text;
        }

        return this.text.substr(0, this.charLimit) + '...';
    }
}
